<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>产品管理</title>
	<meta name="decorator" content="default"/>
	<style type="text/css">
	
	/*底部分页*/
			
			.button_ul a {
				float: left;
				margin-left: 20px;
				padding: 0 8px 0 8px;
				font-weight: bold;
				background: #F6F6FB;
				color: #3399CC;
				font-family: '黑体';
			}
			
			.button_ul .this_page {
				background: #CACACA;
			}
			
			.color:visited {
				color: #35B0EE;
				text-decoration: none;
				font-weight: bold;
			}
			
			.color:hover {
				text-decoration: underline;
			}
	
	</style>
	
	<script type="text/javascript">
		$(document).ready(function() {
			$("#btnImportPic").click(function(){
				$.jBox($("#importPicBox").html(), {title:"导入数据", buttons:{"关闭":true}, 
					bottomText:"仅允许导入“zip”格式文件！"});
			});
			
			$("#updateImport").click(function(){
				$.jBox($("#importBox").html(), {title:"导入数据", buttons:{"关闭":true}, 
					bottomText:"导入文件不能超过5M，仅允许导入“xls”或“xlsx”格式文件！"});
			});
			
			
			$("#checkAll").click(function() {        
				$('input[name="subBox"]').attr("checked",this.checked);       
			});
			var $subBox = $("input[name='subBox']");      
			$subBox.click(function(){        
				$("#checkAll").attr("checked",$subBox.length == $("input[name='subBox']:checked").length ? true : false);      
			});
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		
		 function batchDeletes() {
				//判断至少写了一项
				var checkedNum = $("input[name='subBox']:checked").length;
				if (checkedNum == 0) {
					alert("请至少选择一项!");
					return false;
				}
				if (confirm("确定删除所选项目?")) {
					var checkedList = new Array();
					$("input[name='subBox']:checked").each(function() {
						checkedList.push($(this).val());
					});
					$.ajax({
						type : "POST",
						url : ctx+"/product/sfProduct/batchDeletes",
						data : {
							"delitems" : checkedList.toString()
						},
						datatype : "html",
						success : function(data) {
							alert('删除成功!');
							setTimeout("location.reload()", 1000);//页面刷新
						},
						error : function(data) {
							alert('删除失败!');
						}
					});
				}
			}
		
		/*  function ajaxpage() {
			 
			 $.ajax({
					type : "POST",
					url : ctx+"/project/sfProject/",
					data : {
						"delitems" : checkedList.toString()
					},
					datatype : "html",
					success : function(data) {
						alert('删除成功!');
						setTimeout("location.reload()", 1000);//页面刷新
					},
					error : function(data) {
						alert('删除失败!');
					}
				});
			 
		 } */
		 
	</script>
</head>
<body>
	<div id="importPicBox" class="hide">
		<form id="importPicForm" action="${ctx}/product/sfProduct/importPic" method="post" enctype="multipart/form-data" 
		class="form-search" style="padding-left:20px;text-align:center;" onsubmit="loading('正在导入，请稍等...');"><br/>
			<input id="uploadPicFile" name="mfile" type="file" style="width:330px"/><br/><br/>　　
			<input id="btnImportPicSubmit" class="btn btn-primary" type="submit" value="   导    入   "/>
<%-- 			<a href="${ctx}/project/sfProject/import/template">下载模板</a> --%>
		</form>
	</div>
	
	<div id="importBox" class="hide">
		<form id="importForm" action="${ctx}/product/sfProduct/updateimport" method="post" enctype="multipart/form-data" 
		class="form-search" style="padding-left:20px;text-align:center;" onsubmit="loading('正在导入，请稍等...');"><br/>
			<input id="uploadFile" name="file" type="file" style="width:330px"/><br/><br/>　　
			<input id="btnImportSubmit" class="btn btn-primary" type="submit" value="   导    入   "/>
<%-- 			<a href="${ctx}/project/sfProject/import/template">下载模板</a> --%>
		</form>
	</div>
	
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/product/sfProduct/">产品列表</a></li>
		<shiro:hasPermission name="product:sfProduct:edit"><li><a href="${ctx}/product/sfProduct/form">产品添加</a></li></shiro:hasPermission>
	</ul>
	<form:form id="searchForm" modelAttribute="sfProduct" action="${ctx}/product/sfProduct/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		
		
		<ul class="ul-form">
			<li><label>编码：</label>
				<form:input  path="code" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			
			<li class="btns">
				<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
				<input id="btnImportPic" class="btn btn-primary" type="button" value="导入图片"/>
				<input type="button" onclick="batchDeletes()" value="批量删除"  class="btn btn-primary">
				<input type="button" id="updateImport"  value="产品更新"  class="btn btn-primary">
			</li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				
				<th>编码</th>
				<th>产品状态</th>
				<th>产品年代</th>
				<th>累计发货量</th>
				<th>图片存放</th>
				<shiro:hasPermission name="product:sfProduct:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${list}" var="sfProduct">
			<tr>
				
				<td><a href="${ctx}/product/sfProduct/form?id=${sfProduct.id}">
					${sfProduct.code}
				</a></td>
				<td>
					${sfProduct.status}
				</td>
				<td>
					${sfProduct.age}
				</td>
				<td>
					${sfProduct.shipMentCount}
				</td>
				<td>${sfProduct.existImage }</td>
				<shiro:hasPermission name="product:sfProduct:edit"><td>
    				<a href="${ctx}/product/sfProduct/form?id=${sfProduct.id}">修改</a>
					<a href="${ctx}/product/sfProduct/delete?id=${sfProduct.id}" onclick="return confirmx('确认要删除该产品吗？', this.href)">删除</a>
				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	 <div class="pagination">${page}</div> 
	
	
	
</body>
</html>